package com.desktop;

import com.desktop.config.FrameConfig;
import com.desktop.entity.Pet;
import com.desktop.frame.MyFrame;
import com.desktop.thread.MyThread;
import com.desktop.util.MyFileUtil;

import javax.swing.*;

/**
 * @author 粥灰灰
 * @created 2022/2/2
 * @version 1.0
 * @Description 启动
 */
public class MainApplication {
    public static void main(String[] args) {
        Pet pet = new Pet();
        String pn = "elaina";
        String fileType = ".png";
        int start = 0;
        int end = MyFileUtil.imagesCount(pn)-1;
        pet.setPrefix(pn);
        pet.setPetName(pn);
        pet.setFileType(fileType);
        pet.setStart(start);
        pet.setEnd(end);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                //参数r为true代表把图片一次性全部载入内存的方式启动
                MyFrame myFrame = new MyFrame(pet,true, FrameConfig.getPetStandardWidth(),FrameConfig.getPetStandardHeight());
                myFrame.setTray();//开启任务栏图标
                myFrame.setVisible(true);//显示窗口
                MyThread myThread = new MyThread(myFrame,pet);
                myThread.start();
            }
        });
    }
}
